package com.swh.sms.listener;

import com.swh.sms.utils.SmsUtil;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @Author: swh
 * @Description:
 * @Date: 2021/1/16 10:51
 * @Version: 1.0
 */
@Component
@RabbitListener(queues = "ktc_s")
public class SmsListener {

    @Autowired
    SmsUtil smsUtil;

    @RabbitHandler
    public void sendSms (Map<String,String> map){
        String mobile = map.get("mobile");
        String code = map.get("code");

        System.out.println("MQ接收到消息: ");
        System.out.println("手机号："+mobile);
        System.out.println("验证码："+code);
        smsUtil.sendSms(mobile,code);

    }
}
